﻿/*
-----------------------------------------------------------------------------
This source file is part of Cell Cloud.

Copyright (c) 2009-2012 Cell Cloud Team - cellcloudproject@gmail.com

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/

#ifndef CellStuff_h
#define CellStuff_h

#include "CellPrerequisites.h"
#include "CellSerializable.h"

namespace cell
{
/** \addtogroup Core
 *  @{
 */
/** \addtogroup General
 *  @{
 */

class SubjectStuff;
class PredicateStuff;
class ObjectiveStuff;
class AttributiveStuff;
class AdverbialStuff;
class ComplementStuff;

/** 原语素材。
@author
	Jiangwei Xu
*/
class _CellExport Stuff : public GeneralAlloc
{
public:
	/** 语素类型。
	*/
	enum StuffType
	{
		ST_SUBJECT = 1,
		ST_PREDICATE,
		ST_OBJECTIVE,
		ST_ATTRIBUTIVE,
		ST_ADVERBIAL,
		ST_COMPLEMENT,
		ST_UNKNOWN = 0
	};

	/** 构造函数。
	*/
	Stuff(void);

	/** 拷贝构造函数。
	*/
	Stuff(const Stuff& other);

	/** 构造函数。
	*/
	Stuff(StuffType stuffType, const String& value, LiteralBase literalBase);

	/** 构造函数。
	*/
	Stuff(StuffType stuffType, const char* value, LiteralBase literalBase);

	/** 构造函数。
	*/
	Stuff(StuffType stuffType, int value);

	/** 构造函数。
	*/
	Stuff(StuffType stuffType, uint value);

	/** 构造函数。
	*/
	Stuff(StuffType stuffType, long value);

	/** 构造函数。
	*/
	Stuff(StuffType stuffType, ulong value);

	/** 构造函数。
	*/
	Stuff(StuffType stuffType, bool value);

	/** 析构函数。
	*/
	virtual ~Stuff(void);

protected:
	/**
	*/
	explicit Stuff(StuffType stuffType);

public:
	/** 返回语素类型。
	*/
	FORCEINLINE uint8 getType(void) const { return mStuffType; }

	/** 按照字符串形式返回值。
	*/
	const String& getValueAsString(void) const;

	/** 按照整数形式返回值。
	*/
	int getValueAsInt(void) const;

	/** 按照无符号整数形式返回值。
	*/
	uint getValueAsUInt(void) const;

	/** 按照长整数形式返回值。
	*/
	long getValueAsLong(void) const;

	/** 按照无符号长整数形式返回值。
	*/
	ulong getValueAsULong(void) const;

	/** 按照布尔值形式返回值。
	*/
	bool getValueAsBool(void) const;

	/** 返回数值字面义。
	*/
	LiteralBase getLiteralBase(void) const;

protected:
	StuffType mStuffType;
	LiteralBase mLiteralBase;
	String mValue;
};


/** 主语素材。
@author
	Jiangwei Xu
*/
class _CellExport SubjectStuff : public Stuff
{
private:
	/**
	*/
	SubjectStuff(void);
	/**
	*/
	SubjectStuff(const String& value, LiteralBase literal);

public:
	/**
	*/
	SubjectStuff(const SubjectStuff& other);

	/**
	*/
	SubjectStuff(const char* value);
	/**
	*/
	SubjectStuff(const String& value);
	/**
	*/
	SubjectStuff(int value);
	/**
	*/
	SubjectStuff(uint value);
	/**
	*/
	SubjectStuff(long value);
	/**
	*/
	SubjectStuff(ulong value);
	/**
	*/
	SubjectStuff(bool value);

	/**
	*/
	virtual ~SubjectStuff(void);

public:
	/**
	*/
	SubjectStuff& operator=(const SubjectStuff& other);

	friend class PrimitiveSerializer_1_0;
};


/** 谓语素材
*/
class _CellExport PredicateStuff : public Stuff
{
private:
	/**
	*/
	PredicateStuff(void);
	/**
	*/
	PredicateStuff(const String& value, LiteralBase literal);

public:
	/**
	*/
	PredicateStuff(const PredicateStuff& other);

	/**
	*/
	PredicateStuff(const char* value);
	/**
	*/
	PredicateStuff(const String& value);
	/**
	*/
	PredicateStuff(int value);
	/**
	*/
	PredicateStuff(uint value);
	/**
	*/
	PredicateStuff(long value);
	/**
	*/
	PredicateStuff(ulong value);
	/**
	*/
	PredicateStuff(bool value);

	/**
	*/
	virtual ~PredicateStuff(void);

public:
	/**
	*/
	PredicateStuff& operator=(const PredicateStuff& other);

	friend class PrimitiveSerializer_1_0;
};


/** 宾语素材
*/
class _CellExport ObjectiveStuff : public Stuff
{
private:
	/**
	*/
	ObjectiveStuff(void);
	/**
	*/
	ObjectiveStuff(const String& value, LiteralBase literal);

public:
	/**
	*/
	ObjectiveStuff(const ObjectiveStuff& other);

	/**
	*/
	ObjectiveStuff(const char* value);
	/**
	*/
	ObjectiveStuff(const String& value);
	/**
	*/
	ObjectiveStuff(int value);
	/**
	*/
	ObjectiveStuff(uint value);
	/**
	*/
	ObjectiveStuff(long value);
	/**
	*/
	ObjectiveStuff(ulong value);
	/**
	*/
	ObjectiveStuff(bool value);
	/**
	*/
	virtual ~ObjectiveStuff(void);

public:
	/**
	*/
	ObjectiveStuff& operator=(const ObjectiveStuff& other);

	friend class PrimitiveSerializer_1_0;
};


/** 定语素材
*/
class _CellExport AttributiveStuff : public Stuff
{
private:
	/**
	*/
	AttributiveStuff(void);
	/**
	*/
	AttributiveStuff(const String& value, LiteralBase literal);

public:
	/**
	*/
	AttributiveStuff(const AttributiveStuff& other);

	/**
	*/
	AttributiveStuff(const char* value);
	/**
	*/
	AttributiveStuff(const String& value);
	/**
	*/
	AttributiveStuff(int value);
	/**
	*/
	AttributiveStuff(uint value);
	/**
	*/
	AttributiveStuff(long value);
	/**
	*/
	AttributiveStuff(ulong value);
	/**
	*/
	AttributiveStuff(bool value);
	/**
	*/
	virtual ~AttributiveStuff(void);

public:
	/**
	*/
	AttributiveStuff& operator=(const AttributiveStuff& other);

	friend class PrimitiveSerializer_1_0;
};


/** 状语素材
*/
class _CellExport AdverbialStuff : public Stuff
{
private:
	/**
	*/
	AdverbialStuff(void);
	/**
	*/
	AdverbialStuff(const String& value, LiteralBase literal);

public:
	/**
	*/
	AdverbialStuff(const AdverbialStuff& other);

	/**
	*/
	AdverbialStuff(const char* value);
	/**
	*/
	AdverbialStuff(const String& value);
	/**
	*/
	AdverbialStuff(int value);
	/**
	*/
	AdverbialStuff(uint value);
	/**
	*/
	AdverbialStuff(long value);
	/**
	*/
	AdverbialStuff(ulong value);
	/**
	*/
	AdverbialStuff(bool value);
	/**
	*/
	virtual ~AdverbialStuff(void);

public:
	/**
	*/
	AdverbialStuff& operator=(const AdverbialStuff& other);

	friend class PrimitiveSerializer_1_0;
};


/** 补语素材
*/
class _CellExport ComplementStuff : public Stuff
{
private:
	/**
	*/
	ComplementStuff(void);
	/**
	*/
	ComplementStuff(const String& value, LiteralBase literal);

public:
	/**
	*/
	ComplementStuff(const ComplementStuff& other);

	/**
	*/
	ComplementStuff(const char* value);
	/**
	*/
	ComplementStuff(const String& value);
	/**
	*/
	ComplementStuff(int value);
	/**
	*/
	ComplementStuff(uint value);
	/**
	*/
	ComplementStuff(long value);
	/**
	*/
	ComplementStuff(ulong value);
	/**
	*/
	ComplementStuff(bool value);
	/**
	*/
	virtual ~ComplementStuff(void);

public:
	/**
	*/
	ComplementStuff& operator=(const ComplementStuff& other);

	friend class PrimitiveSerializer_1_0;
};

/** @} */
/** @} */
} // end namespace cell

#endif // CellStuff_h
